02. Displaying A Repository's Commits
TIP: In lesson 2 you used
git clone
to clone the blog project. This is the project we'll be using in this lesson. If you skipped cloning the project in the previous lesson, then run the following command to get the project:
$ git clone https://github.com/udacity/course-git-blog-project
Don't forget to
cd
into the project after you've cloned it.
If you have questions about this, review how to Clone An Existing Repo or ask in Knowledge.
First Things, First
SOLUTION:
run the `git status` commandGit Status & Opening The Project
You can see that git status
tells us that there's "nothing to commit, working directory clean". That means we're good to go ahead and check out the project!
So open the project in your favorite code editor. If you haven't yet, take a minute or two to look at the project – look over the CSS and the JavaScript files, but look particularly at the HTML file.
When Was The Heading Added?
SOLUTION:
¯\\_(ツ)_/¯ I can't tell that by looking at the code.Who Added The Heading?
SOLUTION:
No clueThe Git Log Command
Finding the answers to these questions is exactly what git log
can do for us! Instead of explaining everything that it can do for us, let's experience it! Go ahead and run the git log
command in the terminal:
$ git log
The terminal should display the following screen.
Nd016 WebND Ud123 Gitcourse BETAMOJITO L3 11 Git Log Output Explained
Navigating The Log
If you're not used to a pager on the command line, navigating in Less can be a bit odd. Here are some helpful keys:
- to scroll down, press
j
or↓
to move down one line at a timed
to move by half the page screenf
to move by a whole page screen
- to scroll up, press
k
or↑
to move up one line at a timeu
to move by half the page screenb
to move by a whole page screen
- press
q
to quit out of the log (returns to the regular command prompt)
Git records a ton of information when a commit is made. See if you can use git log
to answer the following questions!
Who Made The Commit?
SOLUTION:
Richard KalehoffWhat Is The Message?
QUESTION:
Use git log
to find the commit with the SHA that starts with 8aa6668
. What is the message for that commit?
SOLUTION:
These answers need to be solved by yourself, I believe you can do it
When Was The Commit Made?
SOLUTION:
Mon Dec 5 10:11:51 2016What Is The SHA?
QUESTION:
Use git log
to find the commit that has the message Set article timestamp color
. Which commit belongs to that SHA? Provide the first 7 characters of the SHA.
SOLUTION:
These answers need to be solved by yourself, I believe you can do it
Git Log Recap
Fantastic job! Do you feel your Git-power growing?
Let's do a quick recap of the git log
command. The git log
command is used to display all of the commits of a repository.
$ git log
By default, this command displays:
- the SHA
- the author
- the date
- and the message
…of every commit in the repository. I stress the "By default" part of what Git displays because the git log
command can display a lot more information than just this.
Git uses the command line pager, Less, to page through all of the information. The important keys for Less are:
- to scroll down by a line, use
j
or↓
- to scroll up by a line, use
k
or↑
- to scroll down by a page, use the spacebar or the Page Down button
- to scroll up by a page, use
b
or the Page Up button - to quit, use
q
We'll increase our git log
-wielding abilities in the next lesson when we look at displaying more info.
Why wait?!? Click the link to move to the next lesson!